<!--
// 
// SendComment.vue
// 客户后台
// 
// Created by 区区电脑 on 2024/09/06.
// 
-->
<template>
    <div class="SendComment">
        <el-input v-model="remark" type="textarea" placeholder="发表评论"/>
        <el-button v-if="remark" type="primary" @click="send" style="margin-top: 10px"><el-icon style="margin-right: 4px"><Position /></el-icon> 发表</el-button>
        <el-button v-else type="primary" disabled style="margin-top: 10px"><el-icon style="margin-right: 4px"><Position /></el-icon> 发表</el-button>
    </div>
</template>

<script setup>
import {ref, reactive, computed, onMounted} from "vue";
import {useStore} from "vuex";
import {useRouter} from "vue-router";
import * as api from "../api.js"

const props = defineProps({
    taskId: {type: Number, default: null},
});
const emits = defineEmits(["sended"]);

// 路由
const router = useRouter();
// store
const store = useStore();
const myInfo = computed(() => store.getters.userInfo)
const remark = ref()

async function send() {
    const body = {
        taskId: props.taskId,
        type: 8,
        remark: remark.value,
        fromUserId: myInfo.value.id,
        fromUserName: myInfo.value.realName,
    }
    const {success} = await api.AddDebugLog(body);
    if (!success) return
    $message.success("发表成功")
    remark.value = null;
    emits("sended")
}

onMounted(() => {
})
</script>

<style scoped lang="scss">
.SendComment {
    width: 100%;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
}
</style>